import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import uy.com.dino.samefile.loader.ProjectLoader;
import uy.com.dino.samefile.model.project.BusinessLogicProject;
import uy.com.dino.samefile.service.BusinessLogicProjectService;
import uy.com.dino.samefile.util.SFException;

public class testLN {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		try {

			final String[] SPRING_CONFIG_FILES = { "application-context.xml",
					"application-context-loader.xml",
					"application-context-service-dao.xml" };

			File properFile = new File("config/projectPath.properties");

			Properties properties = new Properties();
			FileInputStream in = new FileInputStream(properFile);
			properties.load(in);

			ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
					SPRING_CONFIG_FILES);

			ProjectLoader<BusinessLogicProject> businessLogicProjectLoader = (ProjectLoader<BusinessLogicProject>) applicationContext
					.getBean("businessLogicProjectLoader");

			BusinessLogicProjectService businessLogicProjectService = (BusinessLogicProjectService) applicationContext
					.getBean("businessLogicProjectService");

			File file = new File(properties.getProperty("LNProjectPath"));

			System.out.println("Loading projects... ");
			BusinessLogicProject businessLogicProject = businessLogicProjectLoader
					.load(file);

			System.out.println("Saving projects... ");

			businessLogicProjectService.insert(businessLogicProject);

			System.out.println("Starting review... ");

		} catch (IOException e) {
			e.printStackTrace();
		} catch (SFException e) {
			e.printStackTrace();
		}
	}

}
